package Tree;

/**
 * @Classname JZ27二叉树的镜像
 * @Description TODO
 * @Date 2023/2/20 23:32
 * @Created by xjl
 */
public class JZ27二叉树的镜像 {

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    public TreeNode mirrorTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        TreeNode left = mirrorTree(root.left);
        TreeNode right = mirrorTree(root.right);
        root.left = right;
        root.right = left;
        return root;
    }
}
